fix: implemented last fetched time of content-types to reduce subsequent build times#116
Open
vkalta wants to merge 2 commits intocontentstack:develop-archivedfrom
Open
fix: implemented last fetched time of content-types to reduce subsequent build times#116vkalta wants to merge 2 commits intocontentstack:develop-archivedfrom
vkalta wants to merge 2 commits intocontentstack:develop-archivedfrom
Conversation
abhishek305
reviewed
Nov 26, 2021
contenttype-data.js
Outdated
| }; | ||
| query.query.uid = { | ||
| $in: config.contentTypes | ||
| }; // const queryParams = { |
Contributor
There was a problem hiding this comment.
remove comment if not required
contenttype-data.js
Outdated
| $in: referredContentTypesList | ||
| } | ||
| }); | ||
| // query.query = JSON.stringify({ uid: { $in: referredContentTypesList } }); |
Contributor
There was a problem hiding this comment.
remove comment if not required
contenttype-data.js
Outdated
| }; | ||
| query.query.uid = { | ||
| $nin: config.excludeContentTypes | ||
| }; // const queryParams = { |
Contributor
There was a problem hiding this comment.
remove comment if not required
Amitkanswal
approved these changes
Nov 26, 2021
abhishek305
approved these changes
Nov 30, 2021
psykzz
reviewed
Dec 14, 2021
| config.cdn = config.cdn ? config.cdn : 'https://cdn.contentstack.io/v3'; | ||
| const typePrefix = config.type_prefix || 'Contentstack'; | ||
|
|
||
| const lastFetchedTimeCacheKey = `${typePrefix.toLowerCase()}-content-type-fetch-time-${config.api_key}`; |
There was a problem hiding this comment.
Instead of making your own key each time, what about a function that returns a key?
const getCacheKey = (name, config) => `${config.type_prefix ?? 'Contentstack'}-${name}-${config.api_key}`;The benefit here is when you want to update the structure (for example i dont think api key is enough in a cache key, due to #117.) it's updated in a single place.
psykzz
reviewed
Dec 14, 2021
|
|
||
| let lastFetchedTime = await cache.get(lastFetchedTimeCacheKey); | ||
| if (!lastFetchedTime) { | ||
| lastFetchedTime = (new Date(null)).toISOString(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements caching of last fetched content-types time, to reduce the subsequent build times.